home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 2.iso / dist / fw_libxml.idb / usr / freeware / include / gnome-xml / valid.h.z / valid.h
C/C++ Source or Header  |  2001-04-12  |  7KB  |  242 lines

  1. /*
  2.  * valid.h : interface to the DTD handling and the validity checking
  3.  *
  4.  * See Copyright for the status of this software.
  5.  *
  6.  * Daniel.Veillard@w3.org
  7.  */
  8.  
  9.  
  10. #ifndef __XML_VALID_H__
  11. #define __XML_VALID_H__
  12.  
  13. #include "tree.h"
  14.  
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18.  
  19. /**
  20.  * an xmlValidCtxt is used for error reporting when validating
  21.  */
  22.  
  23. typedef void (*xmlValidityErrorFunc) (void *ctx, const char *msg, ...);
  24. typedef void (*xmlValidityWarningFunc) (void *ctx, const char *msg, ...);
  25.  
  26. typedef struct _xmlValidCtxt xmlValidCtxt;
  27. typedef xmlValidCtxt *xmlValidCtxtPtr;
  28. struct _xmlValidCtxt {
  29.     void *userData;            /* user specific data block */
  30.     xmlValidityErrorFunc error;        /* the callback in case of errors */
  31.     xmlValidityWarningFunc warning;    /* the callback in case of warning */
  32. };
  33.  
  34. /*
  35.  * ALl notation declarations are stored in a table
  36.  * there is one table per DTD
  37.  */
  38.  
  39. #define XML_MIN_NOTATION_TABLE    32
  40.  
  41. typedef struct _xmlNotationTable xmlNotationTable;
  42. typedef xmlNotationTable *xmlNotationTablePtr;
  43. struct _xmlNotationTable {
  44.     int nb_notations;        /* number of notations stored */
  45.     int max_notations;        /* maximum number of notations */
  46.     xmlNotationPtr *table;    /* the table of attributes */
  47. };
  48.  
  49. /*
  50.  * ALl element declarations are stored in a table
  51.  * there is one table per DTD
  52.  */
  53.  
  54. #define XML_MIN_ELEMENT_TABLE    32
  55.  
  56. typedef struct _xmlElementTable xmlElementTable;
  57. typedef xmlElementTable *xmlElementTablePtr;
  58. struct _xmlElementTable {
  59.     int nb_elements;        /* number of elements stored */
  60.     int max_elements;        /* maximum number of elements */
  61.     xmlElementPtr *table;    /* the table of elements */
  62. };
  63.  
  64. /*
  65.  * ALl attribute declarations are stored in a table
  66.  * there is one table per DTD
  67.  */
  68.  
  69. #define XML_MIN_ATTRIBUTE_TABLE    32
  70.  
  71. typedef struct _xmlAttributeTable xmlAttributeTable;
  72. typedef xmlAttributeTable *xmlAttributeTablePtr;
  73. struct _xmlAttributeTable {
  74.     int nb_attributes;        /* number of attributes stored */
  75.     int max_attributes;        /* maximum number of attributes */
  76.     xmlAttributePtr *table;    /* the table of attributes */
  77. };
  78.  
  79. /*
  80.  * ALl IDs attributes are stored in a table
  81.  * there is one table per document
  82.  */
  83.  
  84. #define XML_MIN_ID_TABLE    32
  85.  
  86. typedef struct _xmlIDTable xmlIDTable;
  87. typedef xmlIDTable *xmlIDTablePtr;
  88. struct _xmlIDTable {
  89.     int nb_ids;            /* number of ids stored */
  90.     int max_ids;        /* maximum number of ids */
  91.     xmlIDPtr *table;        /* the table of ids */
  92. };
  93.  
  94. /*
  95.  * ALl Refs attributes are stored in a table
  96.  * there is one table per document
  97.  */
  98.  
  99. #define XML_MIN_REF_TABLE    32
  100.  
  101. typedef struct _xmlRefTable xmlRefTable;
  102. typedef xmlRefTable *xmlRefTablePtr;
  103. struct _xmlRefTable {
  104.     int nb_refs;            /* number of refs stored */
  105.     int max_refs;        /* maximum number of refs */
  106.     xmlRefPtr *table;        /* the table of refs */
  107. };
  108.  
  109. /* Notation */
  110. xmlNotationPtr        xmlAddNotationDecl    (xmlValidCtxtPtr ctxt,
  111.                      xmlDtdPtr dtd,
  112.                      const xmlChar *name,
  113.                      const xmlChar *PublicID,
  114.                      const xmlChar *SystemID);
  115. xmlNotationTablePtr xmlCopyNotationTable(xmlNotationTablePtr table);
  116. void            xmlFreeNotationTable(xmlNotationTablePtr table);
  117. void            xmlDumpNotationTable(xmlBufferPtr buf,
  118.                      xmlNotationTablePtr table);
  119.  
  120. /* Element Content */
  121. xmlElementContentPtr xmlNewElementContent (xmlChar *name,
  122.                        xmlElementContentType type);
  123. xmlElementContentPtr xmlCopyElementContent(xmlElementContentPtr content);
  124. void             xmlFreeElementContent(xmlElementContentPtr cur);
  125.  
  126. /* Element */
  127. xmlElementPtr       xmlAddElementDecl    (xmlValidCtxtPtr ctxt,
  128.                      xmlDtdPtr dtd,
  129.                      const xmlChar *name,
  130.                      xmlElementTypeVal type,
  131.                      xmlElementContentPtr content);
  132. xmlElementTablePtr xmlCopyElementTable    (xmlElementTablePtr table);
  133. void           xmlFreeElementTable    (xmlElementTablePtr table);
  134. void           xmlDumpElementTable    (xmlBufferPtr buf,
  135.                      xmlElementTablePtr table);
  136.  
  137. /* Enumeration */
  138. xmlEnumerationPtr  xmlCreateEnumeration    (xmlChar *name);
  139. void           xmlFreeEnumeration    (xmlEnumerationPtr cur);
  140. xmlEnumerationPtr  xmlCopyEnumeration    (xmlEnumerationPtr cur);
  141.  
  142. /* Attribute */
  143. xmlAttributePtr        xmlAddAttributeDecl        (xmlValidCtxtPtr ctxt,
  144.                          xmlDtdPtr dtd,
  145.                          const xmlChar *elem,
  146.                          const xmlChar *name,
  147.                          xmlAttributeType type,
  148.                          xmlAttributeDefault def,
  149.                          const xmlChar *defaultValue,
  150.                          xmlEnumerationPtr tree);
  151. xmlAttributeTablePtr xmlCopyAttributeTable  (xmlAttributeTablePtr table);
  152. void             xmlFreeAttributeTable  (xmlAttributeTablePtr table);
  153. void             xmlDumpAttributeTable  (xmlBufferPtr buf,
  154.                          xmlAttributeTablePtr table);
  155.  
  156. /* IDs */
  157. xmlIDPtr    xmlAddID    (xmlValidCtxtPtr ctxt,
  158.                  xmlDocPtr doc,
  159.                  const xmlChar *value,
  160.                  xmlAttrPtr attr);
  161. xmlIDTablePtr    xmlCopyIDTable    (xmlIDTablePtr table);
  162. void        xmlFreeIDTable    (xmlIDTablePtr table);
  163. xmlAttrPtr    xmlGetID    (xmlDocPtr doc,
  164.                  const xmlChar *ID);
  165. int        xmlIsID        (xmlDocPtr doc,
  166.                  xmlNodePtr elem,
  167.                  xmlAttrPtr attr);
  168. int        xmlRemoveID    (xmlDocPtr doc, xmlAttrPtr attr);
  169.  
  170. /* IDREFs */
  171. xmlRefPtr    xmlAddRef    (xmlValidCtxtPtr ctxt,
  172.                  xmlDocPtr doc,
  173.                  const xmlChar *value,
  174.                  xmlAttrPtr attr);
  175. xmlRefTablePtr    xmlCopyRefTable    (xmlRefTablePtr table);
  176. void        xmlFreeRefTable    (xmlRefTablePtr table);
  177. int        xmlIsRef    (xmlDocPtr doc,
  178.                  xmlNodePtr elem,
  179.                  xmlAttrPtr attr);
  180. int        xmlRemoveRef    (xmlDocPtr doc, xmlAttrPtr attr);
  181.  
  182. /**
  183.  * The public function calls related to validity checking
  184.  */
  185.  
  186. int        xmlValidateRoot        (xmlValidCtxtPtr ctxt,
  187.                      xmlDocPtr doc);
  188. int        xmlValidateElementDecl    (xmlValidCtxtPtr ctxt,
  189.                      xmlDocPtr doc,
  190.                                  xmlElementPtr elem);
  191. int        xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
  192.                      xmlDocPtr doc,
  193.                                  xmlAttributePtr attr);
  194. int        xmlValidateAttributeValue(xmlAttributeType type,
  195.                      const xmlChar *value);
  196. int        xmlValidateNotationDecl    (xmlValidCtxtPtr ctxt,
  197.                      xmlDocPtr doc,
  198.                                  xmlNotationPtr nota);
  199. int        xmlValidateDtd        (xmlValidCtxtPtr ctxt,
  200.                      xmlDocPtr doc,
  201.                      xmlDtdPtr dtd);
  202. int        xmlValidateDocument    (xmlValidCtxtPtr ctxt,
  203.                      xmlDocPtr doc);
  204. int        xmlValidateElement    (xmlValidCtxtPtr ctxt,
  205.                      xmlDocPtr doc,
  206.                      xmlNodePtr elem);
  207. int        xmlValidateOneElement    (xmlValidCtxtPtr ctxt,
  208.                      xmlDocPtr doc,
  209.                                  xmlNodePtr elem);
  210. int        xmlValidateOneAttribute    (xmlValidCtxtPtr ctxt,
  211.                      xmlDocPtr doc,
  212.                      xmlNodePtr    elem,
  213.                      xmlAttrPtr attr,
  214.                      const xmlChar *value);
  215. int        xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,
  216.                      xmlDocPtr doc);
  217. int        xmlValidateNotationUse    (xmlValidCtxtPtr ctxt,
  218.                      xmlDocPtr doc,
  219.                      const xmlChar *notationName);
  220. int        xmlIsMixedElement    (xmlDocPtr doc,
  221.                      const xmlChar *name);
  222. xmlAttributePtr    xmlGetDtdAttrDesc    (xmlDtdPtr dtd,
  223.                      const xmlChar *elem,
  224.                      const xmlChar *name);
  225. xmlNotationPtr    xmlGetDtdNotationDesc    (xmlDtdPtr dtd,
  226.                      const xmlChar *name);
  227. xmlElementPtr    xmlGetDtdElementDesc    (xmlDtdPtr dtd,
  228.                      const xmlChar *name);
  229.  
  230. int        xmlValidGetValidElements(xmlNode *prev,
  231.                      xmlNode *next,
  232.                      const xmlChar **list,
  233.                      int max);
  234. int        xmlValidGetPotentialChildren(xmlElementContent *ctree,
  235.                      const xmlChar **list,
  236.                      int *len,
  237.                      int max);
  238. #ifdef __cplusplus
  239. }
  240. #endif
  241. #endif /* __XML_VALID_H__ */
  242.